SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[_Revenue_GetByDate]
        @fromdate DATETIME ,
        @todate DATETIME
    AS 
        BEGIN
--Prescription
            SELECT  [PrescriptionID] ,
                    [PatientCode] ,
                    [PatientName] ,
                    [VAT] ,
                    [Amount] ,
                    [TotalAmount] ,
                    [SalesPerson]
            FROM    [UFPharma].[dbo].[Prescription]
            WHERE   DeliveryDate BETWEEN @fromdate AND @todate AND ISNULL(IsVoid,0)=0
	--export adjust
            SELECT  [StockOutId] ,
                    [StockOutDate] ,
                    [TotalAmount] ,
                    [PreparedBy] ,
                    [Remark]
            FROM    [UFPharma].[dbo].[StockOut]
            WHERE   [StockOutDate] BETWEEN @fromdate AND @todate
                    AND LEFT([StockOutId], 1) = 'E'
	--return goods
            SELECT  [StockOutId] ,
                    [StockOutDate] ,
                    [TotalAmount] ,
                    [PreparedBy] ,
                    [Remark]
            FROM    [UFPharma].[dbo].[StockOut]
            WHERE   [StockOutDate] BETWEEN @fromdate AND @todate
                    AND LEFT([StockOutId], 1) = 'R'
        END
GO
